<script setup lang="ts">
import { onMounted } from 'vue';
import alertOverviewPie from '@/components/ECharts/alertOverviewPie/index.vue';
import { useAlertOverviewStore } from '@/store/modules/earlyWarning/useAlertOverviewStore';
import UNIT_MAP from '@/constants/components/unit';
import COMPONENT_TITLES from '@/constants/components/componentsTitle';

const { waringStatisticsData, waringList } = storeToRefs(useAlertOverviewStore());
const { thirdGeneralClick, initWarningStatistics } = useAlertOverviewStore();

// 在组件挂载时初始化警告统计数据
onMounted(() => {
  initWarningStatistics();
});
</script>

<template>
  <div class="chart-box">
    <div class="statistics-box">
      <div class="statistics-item" v-for="item in waringList" :key="item.id">
        <div class="statistics-item-title">{{ item.name }}</div>
        <div class="statistics-item-content">
          {{ item.value }}
        </div>
      </div>
    </div>
    <alertOverviewPie
      :title="COMPONENT_TITLES.ALERT_OVERVIEW"
      @third-general-click="thirdGeneralClick"
      :echarts-data="waringStatisticsData.echartsData"
    />
  </div>
</template>

<style scoped lang="scss">
.chart-box {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 20px 1fr;

  .statistics-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    .statistics-item {
      width: 50%;
      display: grid;
      grid-template-columns: 1fr 1fr;
      color: white;

      .statistics-item-content {
        font-family: PangMenZhengDao;
        color: #0ff;
        font-size: 19px;
      }
    }
  }
}
</style>
